package com.test;

import java.io.*;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;
import java.lang.reflect.Method;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.*;

public class Agorithm {
	
public static void main(String[] str) throws Exception {
//	String[]ss={"kfdj","hg","89","lsdg","h"};
//	Stack stack=new Stack();
//	for(String s:ss)
//		stack.push(s);
//	for(int i=0;i<6;i++)
//		System.out.println(stack.pop());
    DateFormat df=new SimpleDateFormat();
    System.out.println(df.format(new Date()));
    Date date=new Date();
   date.setTime(11111);
   Thread.sleep(11);
   System.out.println(df.format(date));
	System.out.println(df.getDateInstance());
	
	Reader fr = new InputStreamReader(new FileInputStream("d:\\demo.txt"),"gbk");
	int ch = 0;
	char[] fu=new char[1024];
	while((ch = fr.read())!= -1) { //条件是没有读到结尾
		System.out.println((char)ch); //调用读取流的read方法，读取一个字符。
//		for(char c:fu)
//			System.out.print(c);
	}
	fr.close();
	ss(9222);
	int cd=4;
	Class c=((Integer)cd).getClass();
	System.out.println(c);
	Method [] methods=Stack.class.getMethods();
	for(Method m:methods)
		System.out.println(m);
	Method me=Math.class.getMethod("sqrt", double.class);
	double d=(double) me.invoke(null,6);
	System.out.println(d);
	System.out.wait(1,1);
}

static void i(int i,int j){
	
}
static void i(int i){
	
}
static void i(int ...i){
	System.out.println(i.length);
}

static void ss(int n){
	if(n==1)
		System.out.println("success");
	else
		ss(n-1);
}
}
class Node{
	String val;
	 Node next;
	public Node(String str){
		val=str;
	}
}

class Stack{
	private Node top;
	public String peek(){
		if(top!=null)
		return top.val;
		else
			return null;
	}
	
	public String pop(){
		if(top==null)
			return null;
		Node n=top;
		top=n.next;
		return n.val;
	}
	
	public void push(String str){
		Node n=new Node(str);
		n.next=top;
		top=n;
	}
}


